

const path = require('path');
const staticImg = path.join(__dirname, 'static');

function SensorbitUnoBlocks(Blockly) {
 var base_color = "#179b73";



 //矩阵键盘模块初始化端口
 Blockly.Blocks.microbit_maxtixKeyPadInit = {
    init:function(){
    this.setColour(base_color);
    this.appendDummyInput("")
     .appendField(new Blockly.FieldImage(staticImg+"/49.Matrix Keyboard Module.svg", 84, 42))
       .appendField(Blockly.Msg.MICROBIT_MAXTIXKEYPAD)
       .appendField(new Blockly.FieldDropdown([
        ['P1', "pin1"],
        ['P8', "pin8"],
        ['P12', "pin12"],
        ['P13', "pin13"],
        ['P15', "pin15"],
       ]),"maxtixKeypadCLK")
       .appendField(Blockly.Msg.MICROBIT_DIO)
       .appendField(new Blockly.FieldDropdown([
        ['P1', "pin1"],
        ['P2', "pin2"],
        ['P12', "pin12"],
        ['P14', "pin14"],
        ['P16', "pin16"],
       ]),"maxtixKeypadDIO")
       this.setPreviousStatement(true, null);
       this.setNextStatement(true, null);
       this.setTooltip('');
    }
};

//获取键盘值模块
Blockly.Blocks.microbit_maxtixKeyPadGetValue = {
    init:function(){
    this.setColour(base_color);
    this.appendDummyInput("")
    .appendField(new Blockly.FieldImage(staticImg+"/49.Matrix Keyboard Module.svg", 84, 42))
    .appendField(Blockly.Msg.MICROBIT_MAXTIXKEYPADGETVALUE)
    this.setPreviousStatement(true, null);
       this.setNextStatement(true, null);
       this.setTooltip('');
    }
};

//判断 键盘按钮值模块
Blockly.Blocks.microbit_maxtixKeyPad = {
    init:function(){
    this.setColour(base_color);
    this.appendDummyInput("")
    .appendField(new Blockly.FieldImage(staticImg+"/49.Matrix Keyboard Module.svg", 84, 42))
    .appendField(Blockly.Msg.MICROBIT_MAXTIXKEYPADPRESS)
    .appendField(new Blockly.FieldDropdown([
        ['0', "0"],
        ['1', "1"],
        ['2', "2"],
        ['3', "3"],
        ['4', "4"],
        ['5', "5"],
        ['6', "6"],
        ['7', "7"],
        ['8', "8"],
        ['9', "9"],
        ['A', "10"],
        ['B', "11"],
        ['C', "12"],
        ['D', "13"],
        ['*', "14"],
        ['#', "15"],
    ]),"maxtixKeypad")
    this.appendDummyInput("").appendField("?")
    this.setOutputShape(Blockly.OUTPUT_SHAPE_HEXAGONAL);
        this.setOutput(true, 'Boolean');
        this.setTooltip('');
    }
};


    return Blockly;
}

module.exports = SensorbitUnoBlocks;

